using System;
namespace Biomedica.Propability.StateMachine
{
	public class Triggers : ITriggerListner{
       

        public string Nextstate { set; get; }
        public string Parameter { set; get; }
        public Boolean Logic { set; get; }

       
        

		public Triggers(State s) {
          
            Nextstate = s.Name;
		}

        public Triggers(string nextstate, string parameter, string logic)
        {
            // TODO: Complete member initialization
            this.Nextstate = nextstate;
            this.Parameter = parameter;
            this.Logic = Convert.ToBoolean(logic);
        }

        public Triggers(string Gard2, string parametgername, bool p)
        {
            // TODO: Complete member initialization
            this.Nextstate = Gard2;
            this.Parameter = parametgername;
            this.Logic = p;
        }
	

        public virtual bool IsValid(StateContext context)
        {
            Boolean v = (Boolean)context.EnvirunmentCollection[Parameter];
            bool result=(Logic && v);
            if (result && OnTranstion != null) OnTranstion(context);
            return result;
            
        }

        public OnTranstion OnTranstion
        {
            get;
            set;
        }
    }

}
